﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
        <!--<script language="javascript" src="script/jquery-1.3.2.js" type="text/javascript" ></script>-->
        <script language="javascript" src="script/jquery-1.4.2.min.js" type="text/javascript" ></script>
        <script language="javascript" src="script/jquery-ui-1.8.custom.min.js" type="text/javascript" ></script>
        <script src="script/jquery.autocomplete.js" type="text/javascript"></script>
        <link href="Style/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
     <style type="text/css">
    input 
    {
    	width: 60px;
    	margin-left: 5px;
    }
    </style>
      <script type="text/javascript">
          $(function() {
          $("#txtSymbol").autocomplete("QMG2.ASPX",
            {
                delay: 10,
                width: 250,
                minChars: 1, //至少輸入幾個字元才開始給提示?
                matchSubset: false,
                matchContains: false,
                cacheLength: 0,
                noCache: true, //黑暗版自訂參數，每次都重新連後端查詢(適用總資料筆數很多時)
                onItemSelect: findValue,
                onFindValue: findValue,
                formatItem: function(row) {
                    return "<div style='height:12px'><div style='float:left'>" + row[0] +
                            "</div>" +
                            "<div style='float:right;padding-right:5px;'>" +
                            row[1] + "</div>";
                },
                extraParams: { t: 'qmg2' }, 

                autoFill: false,
                mustMatch: true //是否允許輸入提示清單上沒有的值?
            });
              function findValue(li) {
                  if (li == null) return alert("No match!");
                  $("#txtSymbol").val(li.selectValue);
                  $("#txtCName").val(li.extra[0]);              
              }
          });
    </script>
</head>
<body>
    <input type="text" id="txtSymbol" />
    <input type="text" id="txtCName" readonly="readonly" style="background-color: #cccccc;width:150px;border:0px;" />
</body>
</html>